﻿using System;
using System.Windows;

namespace PulseApp
{
    public class CommonResources
    {
        private static CommonResources instance = null;
        private static object syncRoot = new Object();

        

        public static int ROLE_REGULAR = 0;
        public static int ROLE_ADMIN = 1;

        private CommonResources()
        {
        }

        public static CommonResources Instance
        {
            get
            {
                if (instance == null)
                {
                    lock (syncRoot)
                    {
                        if (instance == null) instance = new CommonResources();
                    }
                }
                return instance;
            }
        }

        public double[] getSILevel(int age)
        {
            if (age <= 30)
            {
                return new double[2]{4,7};
            }
            else if (age <= 40)
            {
                return new double[2] { 6, 9 };
            }else if(age <= 50){
                return new double[2] { 7, 9 };
            }
            else if (age <= 70)
            {
                return new double[2] { 7, 10 };
            }
            else
            {
                return new double[2] { 7, 12 };
            }
        }

        private Person person = null;
        private PulseWave pulseWave= null;
        private int userRole = 0;

        public Person getPerson()
        {
            return (Person)Application.Current.Properties["person"];
        }

        public void setPerson(Person person)
        {
            Application.Current.Properties["person"] = person;
        }

        public PulseWave getPulseWave()
        {
            return pulseWave;
        }

        public void setPulseWave(PulseWave pulseWave)
        {
            this.pulseWave = pulseWave;
        }

        public void setRole (int userRole)
        {
            this.userRole = userRole;
        }
        public int getRole ()
        {
            return userRole;
        }
    }
}
